<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
</head>
<script type="text/javascript">
var forward_channel_id = "";
function rowClickAfter(rowIndex,forwardChannelId) {
	forward_channel_id = forwardChannelId;
	var  arrId = document.getElementsByName("check");
	arrId[rowIndex -1 ].checked=true;	
}
function deleteChannel(){
	if(forward_channel_id!=""){
		if(JLUtil.doConfirm("请确认是否需要删除渠道[" + forward_channel_id + "]?")){
		    $.ajax({
		        url:"${ctx}/appChannelForward/delAppChannelForward?forward_channel_id="+forward_channel_id,
		        type: "POST",      
		        dataType:"json",
		        async: false,
		        success: function(data) {
		        	if(data.flag>0){
			            alert("删除成功！");	
			            window.location.reload();
		        	}
		        },
		        error: function() {
		          alert("error");
		        }
		     });
		}
	}else{
		alert("请选择要删除的渠道！");
	}
}
function createChannel(){
	window.location.href="${ctx}/appChannelForward/jumpCreatePage?appid=${appid}";
}
function editChannel(){
	if(forward_channel_id!=""){
		window.location.href="${ctx}/appChannelForward/jumpEditPage?channelid="+forward_channel_id;
	} else {
		alert("请选择要编辑的渠道!");
	}
}
function viewChannel(){
	if(forward_channel_id!=""){
		window.location.href="${ctx}/appChannelForward/jumpEditPage?channelid="+forward_channel_id+"&view=1";
	} else {
		alert("请选择要查看的渠道!");
	}
}
</script>
<body>
<div class="op-btn">
	<input type="button" class="btn btn-default" value="创建转发渠道" onclick="createChannel();"/>
	<input type="button" class="btn btn-default" value="删除转发渠道" onclick="deleteChannel();"/>
	<input type="button" class="btn btn-default" value="编辑转发渠道" onclick="editChannel();"/>
	<input type="button" class="btn btn-default" value="查看转发渠道" onclick="viewChannel();"/>
</div>
<macms:table dataListName="acfList">
<macms:html id="ch" label="选择" innerHtml="<input type=\"radio\" name=\"check\" value=\"15\">" ></macms:html>
<macms:text id="app_id" label="应用标识"></macms:text>
<macms:text id="forward_channel_id" label="渠道标识"></macms:text>
<macms:text id="forward_channel_name" label="渠道名称"></macms:text>
<macms:text id="forward_channel_type" label="渠道类型"></macms:text>
<macms:text id="forward_channel_url" label="渠道通讯地址"></macms:text>
<macms:text id="channel_charset" label="字符编码"></macms:text>
<macms:text id="pack_processor_class" label="组/解包处理类"></macms:text>
</macms:table>
<script type="text/javascript">
	var preRow = null;
	$('tbody tr').bind('click', function() {
	
		var rowIndex = $(this).prevAll().length+1;
		if(rowIndex <1) return;
		
		if(preRow != null){
			preRow.removeClass("active");
		}
		$(this).addClass("active");
		preRow = $(this);

		// 行单击后事件(传入行号，页面标识)
		rowClickAfter(rowIndex,
				$(this).find("td").eq(2).text());
	});
</script>
</body>
</html>